/*
 * 文件名：EventLogJackson2HttpMessageConverter.java
 * 版权：MoonBox 
 * 修改人：Peter
 * 修改时间：2018年10月10日
 * 修改内容：新增
 */
package com.renzhebiao.lkang.request;

import java.io.IOException;

import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonGenerator;

/**
 * JSON转换器
 * 
 * @author 龙汀
 * @since 1.0
 */
public class EventLogJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {

    @Override
    protected void writePrefix(JsonGenerator generator, Object object) throws IOException {
        super.writePrefix(generator, object);
        RequestPayload req = RequestCache.get();
        if (req != null) {
            String resBody = JSON.toJSONString(object);
            // String resBody = Strings.substring(Jsons.toJson(object), 0, 2040);
            req.setResBody(resBody);
        }
    }
}
